﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GDGeek;
using Models;
public class GameDataManager : Singleton<GameDataManager> {

    GameMainSave gamedata;
	// Use this for initialization
	void Start () {
        gamedata = new GameMainSave();

        InitData.InitPersonData();
        InitData.InitTalkKeyValue();

        DontDestroyOnLoad(this);
	}

    public void TestFunc()
    {
        Debug.Log("初始化 GameDataManager");
    }

    public void AddGamePerson( GamePerson p)
    {
        gamedata.person = p;
    }

    public GamePerson GetGamePerson()
    {
       return  gamedata.person ;
    }


    public void AddTalkKeyValue(string key , TalkKeyValue t)
    {
        gamedata.talkdic.Add(key, t);
    }


    public bool GetTalkValueByKey(string key)
    {
        try
        {
            return gamedata.talkdic[key].value;
        }
        catch
        {
            return false;
        }

    
    }

    public void SetTalkValue(string key, bool v)
    {
        try
        {
           gamedata.talkdic[key].value = v;
        }
        catch
        {
            Debug.LogError("设置对话数据失败...");
        }
    }

    //public Dictionary<string, GamePerson> GetPersonDic()
    //{
    //    return gamedata.persondic;
    //}

    public void SetPlayerToDriveTank()
    {
        GamePerson p = gamedata.person;  //GetPersonDic()[personKey];
        p.isDriveTank = true;
    }


    public bool CheckPersonIsDriveTank()
    {
        GamePerson p = gamedata.person;
        return p.isDriveTank ;
    }

   
}
